﻿
@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_MyLayout.cshtml";
}


    <div>

        <fieldset class="layui-elem-field site-demo-button">
            <legend>我的审核</legend>

        </fieldset>
        @*<div class="layui-row layui-form">
            <div class="layui-col-md2 layui-col-md-offset5 " style="margin-top:20px;"><input type="text" id="txt_Select" placeholder="请输入申请人" autocomplete="off" class="layui-input"></div>
            <div class="layui-col-md1" style="margin-top:20px;"> <button class="layui-btn layui-btn-normal" onclick="btn_search()">搜索</button></div>
        </div>*@
        <div class="layui-row">
            <table id="mytable" lay-filter="test"></table>
        </div>
        <script type="text/html" id="toolbarDemo">
            <div class="layui-row">
                <button class="layui-btn layui-btn-sm " lay-event="review"><i class="layui-icon"></i>开始审核</button>
             
            </div>
        </script>

        <script type="text/html" id="stateTpl">
            {{#  if(d.Status == 0){ }}
            <span style="color: #F581B1;">审核中</span>
            {{#  } else if(d.Status == 1) { }}
            <span>审核通过</span>
            {{#  }else if(d.Status == 2) { }}
            <span style="color:#b251f6">已撤销</span>
            {{#  } else if(d.Status == 3) { }}
            <span style="color:red">已被驳回</span>
            {{#  }else if(d.Status == 4) { }}
            <span style="color:#0094ff">已领取</span>
            {{#  }  }}
        </script>

    </div>


<script type="text/javascript">


    var table;
    var active;
    var url = "";
    var action;

    layui.use('table', function () {
        table = layui.table;
        var form = layui.form;
        //第一个实例
        table.render({
            elem: '#mytable'
            , skin: 'line' //行边框风格
            , url: '/WorkFlow/GetConsumableApplyByReviewer' //数据接口
            , toolbar: '#toolbarDemo'
            , cellMinWidth: 90    //  自适应宽度，最短宽度80
            , page: true //开启分页
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: 5 //每页默认显示的数量
            , defaultToolbar: ['filter', 'print', 'exports']//自由配置头部工具栏右侧的图标,导出乱码bug
            , cols: [[ //表头
                { type: 'checkbox', fixed: 'left' }
                //, { field: 'Id', title: 'Id', sort: false, fixed: 'left', width: 70 }
                , { field: 'ModelName', title: '实例类型', sort: false }
                , { field: 'UserName', title: '申请人', align: 'center', sort: false }
                , { field: 'OutGoodsName', title: '领用物品', sort: false }
                , { field: 'OutNum', title: '领用数量', sort: false }
                , { field: 'Reason', title: '领用理由', sort: false }
                , { field: 'ReviewerName', title: '审核人', sort: false }
                , { field: 'Status', title: '审核状态', sort: false, templet: '#stateTpl' }
                , { field: 'AddTime', title: '申请时间', sort: false }         

            ]],

        });
  

        //工具栏事件 注意：上方工具栏是toolbar
        table.on('toolbar(test)', function (obj) {
            debugger;
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'review':
                    //获取选中的个数
                    if (checkStatus.data.length == 1) {
                        //获取选中的信息
                        var data = checkStatus.data;
                        //转成json格式的字符串
                        var strdata = JSON.stringify(data);
                        //转成json格式
                        var jsondata = JSON.parse(strdata);
                        //调用更新的方法
                        btn_apply(jsondata[0].Id);
                    } else {
                        layer.alert("必须选中且只能选中一条信息！");
                    }
                    break;
    
            };
        });
     

    });

    layui.use('layer', function () {
        //触发事件
        var id = "100";
        active = {
            notice: function () {
                //示范一个公告层
                layer.open({
                    type: 1
                    , title: [action, 'font-size:18px;']
                    , closeBtn: 1
                    , area: ['780px', '420px']
                    , shade: 0.8
                    , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                    , btnAlign: 'c'
                    , moveType: 1 //拖拽模式，0或者1
                    , content: '<iframe data-frameid="' + id + '" scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:99%;"></iframe>'

                    , success: function (layero) {
                    }
                    , yes: function (index, layero) {
                        if (confirm('确定要' + action + '吗？')) { //只有当点击confirm框的确定时，该层才会关闭
                            layer.close(index)
                        }
                    }
                    , cancel: function (index, layero) {
                        layer.close(index);
                        debugger;
                        //刷新table                     
                        table.reload('mytable', {
                            url: '/WorkFlow/GetConsumableApplyByReviewer' //数据接口
                        });
                    }
                });
            }

        };
    });

     //申请领用按钮
    btn_apply = function (id) {
        action = "耗材审核";
        url = "/Goods_Consumable/ReviewingIndex?id=" + id + "";
        var othis = $(this);
        active["notice"] ? active["notice"].call(this, othis) : '';
    }




</script>




